﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using AAA.Base.Util;

namespace AAA.TradeLanguage.Data
{
    public class SignalRecord
    {
        private string _strEntrySignalName;

        public string EntrySignalName
        {
            get { return _strEntrySignalName; }
            set { _strEntrySignalName = value; }
        }
        private string _strExitSignalName;

        public string ExitSignalName
        {
            get { return _strExitSignalName; }
            set { _strExitSignalName = value; }
        }
        private DateTime _dtEntryDateTime;

        public DateTime EntryDateTime
        {
            get { return _dtEntryDateTime; }
            set { _dtEntryDateTime = value; }
        }
        private DateTime _dtExitDateTime;

        public DateTime ExitDateTime
        {
            get { return _dtExitDateTime; }
            set { _dtExitDateTime = value; }
        }
        private float _fEntryPrice;

        public float EntryPrice
        {
            get { return _fEntryPrice; }
            set { _fEntryPrice = value; }
        }
        private float _fExitPrice;

        public float ExitPrice
        {
            get { return _fExitPrice; }
            set { _fExitPrice = value; }
        }
        private OrderDirectionEnum _eEntryOrderDirection;

        public OrderDirectionEnum EntryOrderDirection
        {
            get { return _eEntryOrderDirection; }
            set { _eEntryOrderDirection = value; }
        }
        private OrderDirectionEnum _eExitOrderDirection;

        public OrderDirectionEnum ExitOrderDirection
        {
            get { return _eExitOrderDirection; }
            set { _eExitOrderDirection = value; }
        }

        public int Position
        {
            get { return EntryOrderDirection == OrderDirectionEnum.LongEntry ? 1 : -1; }
        }

        private float _fCommission;

        public float Commission
        {
            get { return _fCommission; }
            set { _fCommission = value; }
        }

        private float _fPointMultiple;

        public float PointMultiple
        {
            get { return _fPointMultiple; }
            set { _fPointMultiple = value; }
        }

        private float _fTaxRate;

        public float TaxRate
        {
            get { return _fTaxRate; }
            set { _fTaxRate = value; }
        }

        private int _iContract;

        public int Contract
        {
            get { return _iContract; }
            set { _iContract = value; }
        }


        public float TradeCommission
        {
            get { return Contract * Commission * 2; }
        }

        public double Tax
        {
            get { return NumericHelper.Round((EntryPrice + ExitPrice) * Contract * PointMultiple * TaxRate, 0); }
        }

        public double TradeProfit
        {
            get { return (ExitPrice - EntryPrice) * Position * Contract * PointMultiple; }
        }

        public double Profit
        {
            get
            {
                return TradeProfit -
                       TradeCommission -
                       Tax;
            }
        }

    }
}
